#include <fstream>
#include <iostream>
#include <ctime>
#include <iomanip>
#define LEN 5000
using namespace std;
void read_from_file(const char *filename, int a[], int L)
   {
   ifstream fin(filename); 
	for (int i=0; i<L; i++){
		fin >> a[i];}		
}

void bubbleSort(int lst[],int lstLen){
	while (lstLen--) {
		bool flag=false;
			for (int i = 0; i<lstLen; i++){
				if (lst[i]>lst[i+1]){
					swap(lst[i],lst[i+1]);
					flag = true;					
				}
		}
		if (flag==false) break;}
}


int main() {
	
	int a[LEN];
	read_from_file("m1_sorted.txt",a,LEN);
	unsigned int start = clock();
	bubbleSort(a,LEN);
	unsigned int finish = clock();
	unsigned int t = finish - start;
	cout<<"m1_sorted "<< t<<" milliseconds \n";
	
	read_from_file("m2_reverse.txt",a,LEN);
	start = clock();
	bubbleSort(a,LEN);
	finish = clock();
	t = finish - start;
	cout<<"m2_reverse "<< t << " milliseconds \n";
	
	read_from_file("m3_shuffle.txt",a,LEN);
	start = clock();
	bubbleSort(a,LEN);
	finish = clock();
	t = finish - start;
	cout<<"m3_shuffle "<< t << " milliseconds \n";
	
return 0;
}
